-- UIGameSnapshot
-- Created by chengb Aug/20/2016
-- 游戏截图

UIGameSnapshot = class("UIGameSnapshot", function()
    return cc.Layer:create();
end);

function UIGameSnapshot.create()
    return UIGameSnapshot.new();
end

-- 构造函数
function UIGameSnapshot:ctor()
    self:setName("UIGameSnapshot");

    local node = cc.CSLoader:createNode("layout/snapshot/GameSnapshot.csb");
    self:addChild(node);
    self.node = node;

    local bg = findChildByName(node, "bg");
    bg:loadTexture("images/ui/login/bg2.jpg");

    local titleImg = findChildByName(node, "CT/title");
    titleImg:loadTexture("images/logo/cn_game_name.png");

    -- 适配
    self:resize();
end

-- 调整位置
function UIGameSnapshot:resize()
    local node = self.node;

    local w = cc.Director:getInstance():getOpenGLView():getFrameSize().width;
    local h = cc.Director:getInstance():getOpenGLView():getFrameSize().height;

    local bg = node:getChildByName("bg");
    bg:setPosition(w / 2, h / 2);
    local scaleCo = math.max(w / 768, h / 1136);
    bg:setScale(scaleCo);
end
